package main

import (
	"encoding/json"
	"fmt"
)

type Cat struct {
	Name  string
	Age   int
	Color string
}
type Person struct {
	Name string `json:"name"`
	Age  int    `json:"age"`
}

func main() {
	var cat1 Cat
	cat1.Age = 10
	cat1.Name = "向鹏程"
	cat1.Color = "white"
	fmt.Println(cat1)
	p1 := Person{"xx", 18}
	fmt.Println(p1)
	var p2 *Person = new(Person)
	p2.Name = "xz"
	p2.Age = 18
	fmt.Println(*p2)
	var p3 *Person = &Person{"xx", 18}
	fmt.Println(*p3)

	p4 := Person{"summer", 21}
	jsonStr, err := json.Marshal(p4)
	if err != nil {
		fmt.Println("json处理错误", err)
	} else {
		fmt.Println("json=", string(jsonStr))
	}

}
